package com.fone.player.activity.personal.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class NotifyPagerAdapter extends PagerAdapter {

	private List<View> mListView;
	private List<String> mTitleList ;

	public NotifyPagerAdapter(List<View> listView, List<String> mTitleList) {
		this.mListView = listView;
		this.mTitleList = mTitleList;
	}
	
	

	@Override
	public float getPageWidth(int position) {
		// TODO Auto-generated method stub
		 return super.getPageWidth(position);
		
	}

	@Override
	public CharSequence getPageTitle(int position) {
		if(mTitleList!=null){
			return mTitleList.get(position);
		}
		 return super.getPageTitle(position);
		
	}

	@Override
	public int getCount() {
		if(mTitleList!=null){
			return mListView.size();
		}
		return 0;
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView(mListView.get(position));// 删除页卡
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		// 此方法用来实例化页卡
		container.addView(mListView.get(position));
		return mListView.get(position);
	}

	public void removeData(){
		mListView = null;
		mTitleList = null;
	}
	
}
